import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:flutter_practice/src/seat/seat_view.dart';

import 'fine_seat_view.dart';

///座位页面
class SelectSeatPage extends StatefulWidget {
  const SelectSeatPage({super.key});

  @override
  State<SelectSeatPage> createState() => _SelectSeatPageState();
}

class _SelectSeatPageState extends State<SelectSeatPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("SelectSeatPage"),
      ),
      body: _buildContent(),
    );
  }

  Widget _buildContent() {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Container(color: Colors.red.shade50, height: 56),
        const SizedBox(height: 10),
        Expanded(child: _buildSeat()),
        Container(color: Colors.green.shade50, height: 300),
      ],
    );
  }

  Widget _buildSeat() {
    return FineSeatView(
      rows: 10,
      columns: 16,
      onChanged: (rowIndex, colIndex, state) {
        log('$rowIndex -- $colIndex  ${state.toString()}');
      },
      seatsState: const [
        [
          SeatState.sold,
          SeatState.selected,
          SeatState.empty,
          SeatState.disabled,
          SeatState.unselected,
          SeatState.disabled,
          SeatState.disabled,
          SeatState.unselected,
          SeatState.sold,
          SeatState.unselected,
        ],
        [
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.empty,
          SeatState.empty,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.disabled,
          SeatState.empty,
          SeatState.empty,
          SeatState.empty,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
        ],
        [
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.empty,
          SeatState.empty,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.empty,
          SeatState.empty,
          SeatState.empty,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.sold,
          SeatState.sold,
        ],
        [
          SeatState.unselected,
          SeatState.unselected,
          SeatState.sold,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.empty,
          SeatState.empty,
          SeatState.empty,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.empty,
          SeatState.empty,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
        ],
        [
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.sold,
          SeatState.sold,
          SeatState.sold,
          SeatState.empty,
          SeatState.empty,
          SeatState.empty,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.sold,
          SeatState.sold,
          SeatState.sold,
          SeatState.sold,
          SeatState.sold,
          SeatState.unselected,
          SeatState.empty,
          SeatState.empty,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
        ],
        [
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.empty,
          SeatState.empty,
          SeatState.empty,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.empty,
          SeatState.empty,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
        ],
        [
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.sold,
          SeatState.unselected,
          SeatState.empty,
          SeatState.empty,
          SeatState.unselected,
          SeatState.empty,
          SeatState.empty,
          SeatState.empty,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.sold,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.empty,
          SeatState.empty,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.sold,
          SeatState.unselected,
          SeatState.unselected,
        ],
        [
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.sold,
          SeatState.sold,
          SeatState.sold,
          SeatState.sold,
          SeatState.sold,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.empty,
          SeatState.empty,
          SeatState.empty,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
        ],
        [
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.empty,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
        ],
        [
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.empty,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
          SeatState.unselected,
        ],
      ],
      selectedIcon: "assets/seat_selected.png",
      unSelectedIcon: "assets/seat_unselected.png",
      soldIcon: "assets/seat_sold.png",
      disabledIcon: "assets/seat_selected.png",
    );
  }
}
